Skip to content

Boot a FIT with no kernel load/entry and no device tree - #920

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:versal_fit_noload
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:versal_fit_noload

Conversation

@dgarske

@dgarske dgarske commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Description

A Versal customer FIT built without load/entry on the kernel node and with no fdt sub-image exposed four problems.

No device tree. A kernel-only FIT left dts_addr NULL and do_boot() passed that to the kernel. update_ram.c had its configured-DTB fallback in the else of the FIT branch; update_disk.c had none beyond hal_get_boot_dts(), a weak NULL only hal/cm4.c implements. Both now fall back whenever the FIT yields no device tree, validating the blob and relocating it into the staging window first.

No initrd. fit_load_ramdisk() ran inside the FIT branch against a tree the FIT supplied, so a device tree from the boot firmware never received /chosen/linux,initrd-*. Both loaders defer the fixup until the source is settled, and a ramdisk staged with no tree to name it in is now reported instead of skipped silently.

Truncated addresses. fdt_getprop_address() cast an 8-byte load/entry down to uintptr_t; it now rejects a value the target cannot represent.

Wrong exception level. hal/versal.h defaulted to BOOT_EL1, dropping only the boot core to EL1 while PSCI brings the secondaries up at EL2 - Linux refuses that with CPUs started in inconsistent modes. The default is now BOOT_EL2, matching Xilinx U-Boot; BOOT_EL1=1 still works but must be stated explicitly.

WOLFBOOT_LOAD_KERNEL_ADDRESS stages the FIT kernel at a configured address, mirroring the ramdisk and fpga options, with 0 honoring the FIT. DDR_HIGH_BASE / DDR_HIGH_SIZE / NO_DDR_LOW replace the VERSAL_DDR_HIGH_* defines with AArch64-generic ones; the old spellings are still accepted, an incomplete combination is a build error rather than a silently unmapped window, and these and the exception-level options now survive a make config.

Testing

Validated on a Versal VMK180: the FIT boots with the device tree from the BIF raw partition, and the exception-level change was confirmed by reading Linux's __boot_cpu_mode over JTAG with only BOOT.BIN differing between runs. Hosted tests cover the kernel-only-FIT fallback, the initrd ordering and its failure path on both loaders, and a second build of the FDT suite with the pointer bound narrowed to 32 bits exercises the two-cell rejection on a 64-bit host.

The disk loader has no DTB-digest machinery, so a device tree supplied from outside the FIT is unauthenticated there and LINUX_BOOTARGS always supplies the command line; docs/Targets.md states this, and an fdt sub-image is the way to bring such a tree inside the root of trust. VA-cleaning the actual FIT load destinations before the handoff is left as follow-on work.

@dgarske dgarske self-assigned this Oct 1, 2026
Copilot AI balanced review requested due to automatic review settings October 1, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Two-cell addresses truncate unsafely on 32-bit builds, and the central loader-level initrd regression lacks direct coverage.

Review effort: Balanced
Findings: 1 High severity · 3 Low severity

Open (4)
What changed in this PR

Adds support for booting kernel-only FIT images without kernel load/entry addresses or an embedded device tree.

Changes:

  • Adds configurable FIT kernel relocation and 64-bit address handling.
  • Defers initrd fixups until the final DTB is selected.
  • Adds Versal high-DDR configuration, documentation, CI, and tests.
File Description
src/​fdt.c Adds kernel relocation helper and diagnostics.
src/​update_ram.c Adds DTB fallback and deferred initrd fixup.
src/​update_disk.c Defers initrd fixup and improves address logging.
src/​boot_aarch64.c Prints full-width boot addresses.
include/​fdt.h Declares the kernel-loading API.
include/​target.h.in Exposes the kernel load address.
Makefile Generates the new target setting.
options.mk Defines the kernel relocation option.
tools/​config.mk Persists the new configuration variable.
tools/​unit-tests/​Makefile Enables ramdisk testing.
tools/​unit-tests/​unit-fit-gzip.c Tests relocation and initrd helpers.
tools/​unit-tests/​unit-fdt.c Tests two-cell FIT addresses.
tools/​unit-tests/​unit-update-disk-fit.c Adds the kernel loader stub.
docs/​Targets.md Documents supported FIT layouts.
config/​examples/​versal_vmk180.config Documents optional relocation settings.
config/​examples/​versal_vmk180_highddr.config Adds a high-DDR Versal example.
.github/​workflows/​test-configs.yml Builds the new example in CI.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/unit-tests/unit-fdt.c Outdated
Comment thread config/examples/versal_vmk180_highddr.config Outdated
Comment thread src/fdt.c Outdated
Comment thread tools/unit-tests/unit-fit-gzip.c Outdated
@dgarske
dgarske force-pushed the versal_fit_noload branch 2 times, most recently from 37579ca to 4035401 Compare October 1, 2026 22:09
@dgarske
dgarske requested a balanced review from Copilot October 1, 2026 23:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It changes security-sensitive boot loading, DTB selection, memory relocation, and AArch64 handoff behavior across multiple targets.

Review effort: Balanced
Findings: None

Resolved since last review (4)

@dgarske
dgarske force-pushed the versal_fit_noload branch 4 times, most recently from 6e0f118 to 04c9312 Compare October 13, 2026 19:26
@dgarske dgarske assigned danielinux and wolfSSL-Bot and unassigned dgarske Oct 13, 2026
@dgarske
dgarske requested a review from danielinux October 13, 2026 19:49
@dgarske
dgarske requested a balanced review from Copilot October 13, 2026 21:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

High-DDR options can be silently discarded or ignored, and the 32-bit truncation fix lacks executed regression coverage.

4 open findings

🧠 Review effort: Balanced

Comment thread options.mk
Comment thread options.mk
Comment thread src/fdt.c Outdated
Comment thread tools/unit-tests/unit-fdt.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Kernel relocation lacks cache cleaning for the actual destination, and the Versal documentation contains conflicting exception-level defaults.

2 open findings
4 resolved since last review

🧠 Review effort: Balanced

Comment thread src/fdt.c
Comment thread docs/Targets.md
@dgarske
dgarske force-pushed the versal_fit_noload branch 2 times, most recently from edd71d7 to 451ede5 Compare October 13, 2026 23:03
@dgarske
dgarske requested a balanced review from Copilot October 13, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Actual FIT destinations need cache cleaning, and make config must preserve explicit exception-level settings.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Comment thread tools/config.mk

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Kernel relocation can overwrite the live FIT, and the ramdisk API documentation no longer matches its behavior.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread src/fdt.c
Comment thread src/fdt.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants